<template>
	<view class="work-container">
		<!-- 搜索框-->
		<uni-search-bar @confirm="handleQuery"  v-model="queryParams.pigCode" placeholder="请输入耳号"
			bgColor="#ffffff" >
		</uni-search-bar>
		<uni-group mode="card" v-for="(item, index) in pigPregnancyList" :index="index" :key="index">
			<view class="code">
				<text style="font-size:18px">母猪耳号：{{item.pigCode}}</text>
				<uni-icons class="icon" type="right" size="15" color="#000000"
						   @click="toDetials(item.pregnancyId)"></uni-icons>
			</view>
			<hr/>
			<view class="message">
				<view  v-if="item.pigPregnancyType ==1"> 妊检方式：{{$dict.selectDictLabel('hmy_pig_pregnancy_type', 1)}} </view>
				<view  v-else-if="item.pigPregnancyType ==2"> 妊检方式：{{$dict.selectDictLabel('hmy_pig_pregnancy_type', 2)}} </view>
				<view  v-else-if="item.pigPregnancyType ==3"> 妊检方式：{{$dict.selectDictLabel('hmy_pig_pregnancy_type', 3)}} </view>
				<view  v-else-if="item.pigPregnancyType ==4"> 妊检方式：{{$dict.selectDictLabel('hmy_pig_pregnancy_type', 4)}} </view>
				<view  v-if="item.pregnancyTestResult ==1"> 妊检结果：{{$dict.selectDictLabel('hmy_pregnancy_test_result', 1)}} </view>
				<view  v-else-if="item.pregnancyTestResult ==2"> 妊检结果：{{$dict.selectDictLabel('hmy_pregnancy_test_result', 2)}} </view>
				<view> 妊检管理员：{{item.hmyStaff.staffName}}</view>
				<view> 妊检日期：{{item.pregnancyTime}}</view>
			</view>
		</uni-group>
		<!-- 加载更多 -->
		<uni-load-more iconType="auto" :status="status" />
		<uni-fab :pattern="pattern" :horizontal="horizontal" :vertical="vertical"
				@fabClick="fabClick" />
	</view>

</template>

<script>


import { listPigPregnancy} from "@/api/hmy/pigPregnancy";

export default {
  name: "PigPregnancy",
  dicts: ['hmy_pregnancy_test_type','hmy_pregnancy_test_result'],
  data() {
    return {
		//搜索值
		searchValue: '',
		// 猪只分娩记录数据
		pigPregnancyList: [],
		// 水平方向
		horizontal: 'right',
		// 垂直方向
		vertical: 'bottom',

		pattern: {
			buttonColor: '#55aa7f',
		},
		//加载更多
		status: 'more',
		total: '',
		// 查询参数
		queryParams: {
			pageNum: 1,
			pageSize: 10,
			type: undefined,
		}
	};

	},

	  created() {
		  this.getList();
	  },
	  //上拉加载
	  onReachBottom() {
		  this.queryParams.pageSize += 5;
		  this.getList();
		  if (this.pigPregnancyList.length >= this.total) {
			  this.status = 'noMore';
		  } else {
			  this.status = 'loading';
		  }
	  },
	  methods: {
		  /** 查询猪只出场记录列表 */
		  getList() {
			  uni.showLoading({
			  	title:"加载中"
			  })
			  listPigPregnancy(this.queryParams).then(response => {
				  //console.log(response)
				  this.pigPregnancyList = response.rows;
				  this.total = response.total;
				  uni.hideLoading();
			  });
		  },

		  ///  新增猪只分娩记录
		  fabClick() {
			  this.$tab.navigateTo('/pages/hmy/pigPregnancy/pigPregnancyAdd');
		  },
		  /** 搜索按钮操作 */
		  handleQuery() {
			  this.queryParams.pageNum = 1;
			  this.getList();
		  },

		  //详情
		  toDetials(e) {
			  console.log("xiangqing",e)
			  this.$tab.navigateTo('/pages/hmy/pigPregnancy/pigPregnancyDetials?id='+e);
		  }

	  }
};
</script>
<style lang="scss">

  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 100%;
    height: auto;
	background-color: #fcfcfc;
  }

  view {
    font-size: 16px;
    line-height: inherit;
  }
  /* #endif */
  .code{
	margin-bottom :5px;
  }
  .icon{
	float:right;
	margin-right:10px;
	margin-top :5px;
  }
  .message{
	margin-top:5px;
	color: #989897;
	line-height: 25px;
  }
</style>
